
import tkinter
from PIL import Image

#建立窗体
win = tkinter.Tk()
win.title('简易绘图画板')
win.geometry("800x500+100+100")

#控制是否允许画图，1为允许，0为不允许
yesno = tkinter.IntVar(value = 0)
#控制画图类型，1为曲线，2为直线，3为矩形，4为文本，5为橡皮
shat = tkinter.IntVar(value = 1)
#记录鼠标位置
x = tkinter.IntVar(value = 0)
y = tkinter.IntVar(value = 0)
#前景色与背景色
foreColor = '#000000'
backColor = '#FFFFFF'
#创建画布
image = tkinter.PhotoImage()
canvas = tkinter.Canvas(win,bg='white',width=800,height=600)
canvas.create_image(800,600, image=image)

#画图事件
def onLeftButtonDown(event):
	yesno.set(1)
	x.set(event.x)
	y.set(event.y)
	if what.get() == 4:   #输出文本
		canvas.create_text(event.x, event.y, text = text)
canvas.bind('<Button-1>', onLeftButtonDown)

win.mainloop()
